package com.android.hedgehog.puzzles;

import java.util.Random;

public class GoalieEngine {
	static final Random rand = new Random();
	String msg = ""; // test
	String msg2 = ""; // test
	int dX, dY, width;
	double slope;
	int slopeFactor;
	int difficulty;
	Puck puck;
	Block block;

	public GoalieEngine(int difficulty) {
		this.difficulty = difficulty;
		configure(difficulty);

	}

	private void configure(int lev) {
		// width = 80 - ((lev + 1) / 2) * 10; // width:30-70
		width = 50;

		do {

			while (true) {
				dX = -250 + rand.nextInt(501);
				dY = -250 + rand.nextInt(501);
				slope = ((double) dY / (double) dX);
				if (lev < 6 && Math.abs(slope) > (3 - (lev * .4)) && Math.abs(slope) < (3 - ((lev - 1) * .4))
						&& dY > 0)
					break;
				if (lev == 6 && Math.abs(slope) > (.81) && Math.abs(slope) < (1) && dY > 0)
					break;
				if (lev == 7 && Math.abs(slope) > (.67) && Math.abs(slope) < (.81) && dY > 0)
					break;
				if (lev == 8 && Math.abs(slope) > (.51) && Math.abs(slope) < (.67) && dY > 0)
					break;
				if (lev == 9 && Math.abs(slope) > 1.2 && Math.abs(slope) < 1.5 && dY < 0)
					break;
				if (lev == 10 && Math.abs(slope) > (.9) && Math.abs(slope) < (1.2) && dY < 0)
					break;
			}

		} while (Math.abs(dY) < 30 || Math.abs(dX) + Math.abs(dY) < 100); // Universal
																			// restraints

		msg = "x: " + dX + " y: " + dY + " SLOPE:" + slope + " d: " + lev; // test
		puck = new Puck(100.0f + rand.nextFloat() * 120, 60.0f + rand.nextFloat() * 80, dX, dY);
		block = new Block(width);
	}
}
